package Hard;

public class Solution466 {

    public static void main(String[] args) {
        System.out.println(getMaxRepetitions("acb",4,"ab",2));
    }

    public static int getMaxRepetitions(String s1, int n1, String s2, int n2) {
        String str1 = getString(s1,n1);
        String str2 = getString(s2,n2);
        // 由getString(str2,m)构建得到str
        // 使str1变成str，求m的最大值
        int m = calM(str1,str2);
        return m;

    }


    public static String getString(String s , int n){
        String str = "";
        for(int i = 0 ; i < n ; i++){
            str+=s;
        }
        return str;
    }

    public static int calM(String str1 , String str2){
        int i = 0 , j = 0;
        int M = 0;
        while(i < str1.length()){
            if(str2.charAt(j) == str1.charAt(i)){
                j++;
                if(j == str2.length()){
                    j = 0;
                    M++;
                }
            }
            i++;

        }
        return M;
    }
}
